/**
 * 用户相关类型定义
 */

export enum GenderEnum {
  MALE = 'male',
  FEMALE = 'female',
  OTHER = 'other'
}

export interface User {
  id: number
  username: string
  email: string
  nickname?: string
  avatar?: string
  bio?: string
  gender?: GenderEnum
  location?: string
  created_at: string
  is_active: boolean
  is_verified: boolean
}

export interface UserProfile extends User {
  phone?: string
  birthday?: string
  last_login_at?: string
  login_count: number
  updated_at?: string
  preferences?: UserPreference
}

export interface UserPreference {
  id: number
  user_id: number
  favorite_avatar_id?: number
  favorite_novels?: number[]
  favorite_characters?: number[]
  language: string
  theme: string
  voice_enabled: boolean
  voice_speed: number
  auto_play_voice: boolean
  notification_enabled: boolean
  privacy_settings?: Record<string, any>
  created_at: string
  updated_at?: string
}

export interface UserRegister {
  username: string
  email: string
  password: string
  nickname?: string
}

export interface UserLogin {
  username: string
  password: string
}

export interface UserUpdate {
  nickname?: string
  bio?: string
  phone?: string
  gender?: GenderEnum
  birthday?: string
  location?: string
  avatar?: string
}

// 密码修改
export interface UserPasswordChange {
  old_password: string
  new_password: string
}

export interface UserPreferenceUpdate {
  favorite_avatar_id?: number
  favorite_novels?: number[]
  favorite_characters?: number[]
  language?: string
  theme?: string
  voice_enabled?: boolean
  voice_speed?: number
  auto_play_voice?: boolean
  notification_enabled?: boolean
  privacy_settings?: Record<string, any>
}

// 用户统计信息
export interface UserStats {
  login_count: number
  last_login_at?: string
  created_at: string
  favorite_novels_count: number
  favorite_characters_count: number
  is_verified: boolean
}

// 认证令牌
export interface Token {
  access_token: string
  refresh_token: string
  token_type: string
  expires_in: number
}

export interface ApiResponse<T = any> {
  code: number
  message: string
  data?: T
}

export interface UserResponse extends ApiResponse<User> {}
export interface UserProfileResponse extends ApiResponse<UserProfile> {}
export interface UserPreferenceResponse extends ApiResponse<UserPreference> {}
export interface UserStatsResponse extends ApiResponse<UserStats> {}
export interface TokenResponse extends ApiResponse<Token> {}

export interface UserState {
  currentUser: User | null
  userProfile: UserProfile | null
  token: string | null
  refreshToken: string | null
  isLoggedIn: boolean
  loading: boolean
} 